package khleuven.mondzorg.app;

import java.util.Arrays;
import java.util.List;

import khleuven.mondzorg.R;
import khleuven.mondzorg.domain.EntryType;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends ActivityWithSettingsAndHelp {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_main);
		
		
		ListView  myListView = (ListView)findViewById(R.id.moduleList);
		String[] modules = getResources().getStringArray(R.array.Modules); 
		List<String> modulelijst = Arrays.asList(modules);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.modulelist_item, modulelijst);
		myListView.setAdapter(adapter);
		
		myListView.setOnItemClickListener(new OnItemClickListener() {
			  @Override
			  public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
			    switch (pos) {
				case 0:					
	                startActivity(new Intent(MainActivity.this, DefinitionsActivity.class));
					break;
				case 1:
					startActivity(new Intent(MainActivity.this, FaqsActivity.class));
					break;
				case 2:
					Intent intent1 = new Intent(MainActivity.this, ModulesActivity.class);
		      		intent1.putExtra(ModulesActivity.ORIGIN_KEY, EntryType.LEARN.name());
		      		startActivity(intent1);	
					break;
				case 3:
					Intent intent2 = new Intent(MainActivity.this, ModulesActivity.class);
		      		intent2.putExtra(ModulesActivity.ORIGIN_KEY, EntryType.TEST.name());
		      		startActivity(intent2);	
					break;
				default:
					break;
				}
			  }
			});

	}
}